package Properties;

import java.io.InputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.FileInputStream;


public class PropertyFiles {

    public static void saveProperties(MyProp p, String fileName) {
        OutputStream propsFile;
        try {
            propsFile = new FileOutputStream(fileName);
            p.store(propsFile, "Properties File to the Test Application");
            propsFile.close();
        } catch (IOException ioe) {
            System.out.println("I/O Exception.");
            ioe.printStackTrace();
            System.exit(0);
        }
    }

    public static MyProp loadProperties(String fileName) {
        InputStream propsFile;
        MyProp tempProp = new MyProp();
        try {
            propsFile = new FileInputStream(fileName);
            tempProp.load(propsFile);
            propsFile.close();
        } catch (IOException ioe) {
            System.out.println("I/O Exception.");
            ioe.printStackTrace();
            System.exit(0);
        }
        return tempProp;
    }
}
